//
//  HZHeadlineView.m
//  MyDoctor
//
//  Created by 黑眼圈 on 16/5/4.
//  Copyright © 2016年 heiyan. All rights reserved.
//

#import "HZHeadlineView.h"


//define this constant if you want to use Masonry without the 'mas_' prefix
#define MAS_SHORTHAND
//define this constant if you want to enable auto-boxing for default syntax
#define MAS_SHORTHAND_GLOBALS

#import "Masonry.h"

@interface HZHeadlineView()

@property(nonatomic,strong)UIImageView*  icon;
@property(nonatomic,strong)UILabel*  label;

@end

@implementation HZHeadlineView



- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        //设置并添加子控件
        [self setupUI];
    }
    return self;
}

#pragma mark -
#pragma mark    设置并添加子控件
-(void)setupUI{
    
    self.backgroundColor = [UIColor whiteColor];
    
    //添加子控件
    [self addSubview:self.icon];
    [self addSubview:self.label];
    
    
    //约束
    [self.icon makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.equalTo(15);
        make.centerY.equalTo(self);
        make.top.equalTo(7);
        make.bottom.equalTo(-7);
 
    }];
    
    [self.label makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.equalTo(self.icon.trailing).offset(15);
        make.centerY.equalTo(self.icon);
      
    }];
    
}


#pragma mark -
#pragma mark     懒加载子控件
-(UIImageView *)icon{
    if (!_icon) {
        
        _icon = [[UIImageView alloc]init];
        _icon.image = [UIImage imageNamed:@"yj"];
        _icon.contentMode = UIViewContentModeScaleAspectFill;

    }
    return _icon;
}

-(UILabel *)label{
    if (!_label) {
        
        _label = [[UILabel alloc]init];
        _label.text = @"名医通";
        _label.font = [UIFont systemFontOfSize:15];
    }
    return _label;
}


@end
